home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 1997 April to September / Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso / products / Confluent / note_packinfo.txt < prev    next >
Text File  |  1995-10-17  |  4KB  |  126 lines

  1. ----------------------------------------------------------------------
  2. Mailing Compressed Directories and Binary Files
  3.  
  4. Last update: 16 August 1995
  5.  
  6. Confluent Technical Notes
  7. Copyright (c) 1995 Confluent, Inc.  All rights reserved.
  8. Suggestions or questions to 415-586-8700 or vthought@confluent.com.
  9. ----------------------------------------------------------------------
  10.  
  11. This technical note describes techniques for efficiently sending
  12. multiple directories and files via email.
  13.  
  14. It is often useful to send directories, large files, and/or binary
  15. files via email.  For example:
  16.  
  17.   Visual Thought documents
  18.   screen shots (e.g., images obtained with Options->XGrab->Selection in VT)
  19.   images (e.g., GIF files)
  20.  
  21. To accomplish this easily and efficiently, the information should be
  22. placed in an archive, compressed, and converted to a text form that
  23. can be attached to or included in an email message.  This approach
  24. offers the following advantages:
  25.  
  26.  1. It handles multiple files, multiple directories, and entire
  27.     directory structures with a single command without requiring
  28.     individual treatment of each file.  One email attachment can be
  29.     generated for all files and directories being sent.
  30.  
  31.  2. It deals with binary files in a transparent manner.  There is no
  32.     need to encode them separately.
  33.  
  34.  3. It can significantly reduce the size of the resulting email
  35.     message.  Some files, such as Visual Thought documents, can be
  36.     compressed substantially.
  37.  
  38. The packinfo csh script attached to the end of this note archives,
  39. compresses, and uuencodes specified files and/or directories for
  40. transmission via email.  To set up packinfo, extract it from this note
  41. (get everything between the "===== begin" and "===== end" lines),
  42. place it in the file packinfo, and make it executable with:
  43.  
  44.   chmod +x packinfo
  45.  
  46. The packinfo script uses the gzip command, if available, because gzip
  47. achieves much better compression than compress.  If you do not have
  48. gzip, but you do have gunzip, you can create gzip by creating a link
  49. from gunzip to gzip (they are the same executable with different
  50. names) with:
  51.  
  52.   ln gunzip gzip
  53.  
  54. If you do not have gunzip, packinfo will use compress instead.  If you
  55. want a copy of gunzip, let us know and we will get you a copy.
  56.  
  57. Execute packinfo with:
  58.  
  59.   packinfo <file(s)>
  60.  
  61. where <file(s)> are the paths of one or more files and/or directories.
  62.  
  63. Packinfo creates the file data.uue, which is in text form.  It can be
  64. attached directly to a mail message (e.g., in mailtool) or included in
  65. the text of a mail message.
  66.  
  67. The contents of data.uue can be recovered with:
  68.  
  69.   uudecode data.uue
  70.   gunzip data.tar
  71.   tar xf data.tar
  72.  
  73. Replace gunzip with uncompress in the above commands if the first line
  74. of data.uue contains data.tar.Z, rather than data.tar.gz (i.e.,
  75. packinfo used compress instead of gzip).
  76.  
  77.  
  78. ===== begin packinfo =====
  79. #!/bin/csh -f
  80.  
  81. # Indicate usage.
  82. if ($#argv < 1) then
  83.   set cmd = $0
  84.   echo "usage: $cmd:t <file(s)>"
  85.   echo ""
  86.   echo "  Archives, compresses, and uuencodes <file(s)> to data.uue, which can"
  87.   echo "  be attached to mail (e.g., in mailtool) or included in a mail message."
  88.   echo ""
  89.   exit
  90. endif
  91.  
  92. # Determine which compression command to use by finding the first
  93. # command in $cmd_array that exists in the command search path.
  94. set cmd_array = ("gzip" "compress")
  95. set ext_array = ("gz"   "Z")
  96. @ index = 0
  97. @ i = 0
  98. while ($i < $#cmd_array)
  99.   @ i ++
  100.   foreach dir ($path)
  101.     if (-x $dir/$cmd_array[$i]) then
  102.       set index = $i
  103.       break; break
  104.     endif
  105.   end
  106. end
  107.  
  108. # Indicate that none of the compression commands could be found.
  109. if ($index == 0) then
  110.   echo ""
  111.   echo "None of the following compression commands could be found in your"
  112.   echo "command search path:"
  113.   echo ""
  114.   echo "   $cmd_array"
  115.   echo ""
  116.   exit
  117. endif
  118.  
  119. # Generate the output file.
  120. set ext = $ext_array[$index]
  121. tar cf data.tar $*
  122. $cmd_array[$index] data.tar
  123. uuencode data.tar.$ext data.tar.$ext > data.uue
  124. rm data.tar.$ext
  125. ===== end packinfo =====
  126.